﻿using System.Windows;
using System.Windows.Controls;

namespace Brjnk.GpxExplorer.UI
{
    /// <summary>
    /// Interaction logic for DetailsWindow.xaml
    /// </summary>
    public partial class DetailsWindow : Window
    {
        private ContentControl placeHolder;

        public DetailsWindow(ContentControl placeHolder)
        {
            InitializeComponent();
            Initialize(placeHolder);
            this.Closing += new System.ComponentModel.CancelEventHandler(DetailsWindow_Closing);
        }

        private void DetailsWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var element = this.content.Content;
            this.content.Content = null;
            placeHolder.Content = element;
        }

        private void Initialize(ContentControl placeHolder)
        {
            this.placeHolder = placeHolder;
            var element = placeHolder.Content;
            placeHolder.Content = null;

            this.content.Content = element;
        }
    }
}